<?php
/**
 * 这是一个神奇的Dock类
 *
 * @author ananda
 */
class Dock extends Kernel
{

    public function __set($name, $value)
    {
        Com::glob("com.dock.$name", $value);
    }

    public function __get($name)
    {
        if (!isset($this->$name)) {
            // 检查主配置文件中的组件配置
            $component = Com::glob('com.component');
            if (!isset($component[$name])) {
                throw new Exception_Kernel("Component [$name] not registered");
            }

            // 根据配置创建
            $params = isset($component[$name]['params']) ? $component[$name]['params'] : array();
            $this->$name = new $component[$name]['class']($params);
        }
        return Com::glob("com.dock.$name");
    }

    public function __isset($name)
    {
        return Com::glob("com.dock.$name") !== null;
    }

    public function __unset($name)
    {
        Com::glob("com.dock.$name", null);
    }
}
